<?php
    // +----------------------------------------------------------------------
    // | 海豚PHP框架 [ DolphinPHP ]
    // +----------------------------------------------------------------------
    // | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
    // +----------------------------------------------------------------------
    // | 官方网站: http://dolphinphp.com
    // +----------------------------------------------------------------------
    // | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
    // +----------------------------------------------------------------------

    namespace app\store\validate;

    use think\Validate;

    /**
     * 行为验证器
     *
     * @package app\cms\validate
     * @author  蔡伟明 <314013107@qq.com>
     */
    class Address extends Validate
    {

        //定义验证规则
        protected $rule = [
            'address_area|地区(省市区)' => 'require',
            'name|收货人'             => 'require',
            'mobile|手机号码'          => 'require|number|regex:^1\d{10}',
            'address_detail|详细地址'  => 'require',
            'is_default|是否为默认地址'   => 'require'
        ];

        //定义验证提示
        protected $message = [
            'name.regex' => '行为标识由字母和下划线组成',
        ];

        // 定义验证场景
        protected $scene = [
            'add'    => ['address_area','name','mobile','address_detail','is_default'],
            'update' => ['address_area','name','mobile','address_detail','is_default'],

        ];
    }
